from django.db import models

# Create your models here.
class Cate(models.Model):
    name = models.CharField(max_length=32,verbose_name="分类名称")

    class Meta:
        db_table = "cates"
        verbose_name = "分类表"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name


class Goods(models.Model):
    name = models.CharField("商品名",max_length=32)
    desc = models.CharField("简介",max_length=256)
    price = models.DecimalField(max_digits=6, decimal_places=2, verbose_name='价格')
    unit = models.CharField("单位",max_length=32)
    store = models.IntegerField('库存')
    cate = models.ForeignKey(Cate,on_delete=models.CASCADE,verbose_name="所属分类")
    pic = models.ImageField(upload_to="static/pic",verbose_name="首图")
    content = models.TextField('内容')

    class Meta:
        db_table='goods'
        verbose_name='商品表'
        verbose_name_plural=verbose_name

    def __str__(self):
        return self.name

